package com.angis.fx.activity.sxry;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.InputType;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.angis.fx.activity.Enforcement;
import com.angis.fx.activity.R;
import com.angis.fx.data.ContextInfo;

public class SxryActivity extends Activity {
	TextView l_qtryTitle;
	EditText editText;
	EditText memberEditText;
	private boolean isClear;
	public static String QTRY_EDIT_MEMBER="";
	public static int QTRY_EDIT_MEMBER_COUNT = 0;
	
	Button s_button_ok2;
	Button s_button_other_to_main;
	Bundle bundle ;
	// Button s_button;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sxry);
		 bundle = this.getIntent().getExtras();
		isClear = bundle.getBoolean("isClear");
		
		ContextInfo contextInfo = (ContextInfo) bundle.get("contextInfo");
		memberEditText=(EditText) findViewById(R.id.s_member_num);
		memberEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
		editText=(EditText) findViewById(R.id.textContext);
		l_qtryTitle=(TextView) findViewById(R.id.qtry_title);
		l_qtryTitle.setText(contextInfo.getOrganizationInfo().getName());
		if(!isClear){
			editText.setText(QTRY_EDIT_MEMBER);
		}
		
		s_button_ok2=(Button) findViewById(R.id.s_button_ok2);
		s_button_other_to_main=(Button) findViewById(R.id.s_button_other_to_main);
		s_button_ok2.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				if(!"其他人员".equals(editText.getText().toString()))
					QTRY_EDIT_MEMBER=editText.getText().toString();
				
				String n=memberEditText.getText().toString();
				if(n!=null && !n.equals("")){
					try {
						QTRY_EDIT_MEMBER_COUNT=Integer.parseInt(n);
					} catch (NumberFormatException e) {
					}
				}
				//QTRY_EDIT_MEMBER_COUNT=
				if(isClear){
					Intent intent = new Intent();
					//Bundle bundle=this.getIntent().getExtras();
					intent.setClass(SxryActivity.this, Enforcement.class);
					intent.putExtras(bundle);
					SxryActivity.this.startActivity(intent);
				
					}
				SxryActivity.this.finish();
				
			}
		});
		s_button_other_to_main.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				if(!"其他人员".equals(editText.getText().toString()))
					QTRY_EDIT_MEMBER=editText.getText().toString();
					String n=memberEditText.getText().toString();
					if(n!=null && !n.equals("")){
						try {
							QTRY_EDIT_MEMBER_COUNT=Integer.parseInt(n);
						} catch (NumberFormatException e) {
						}
					}
					Intent intent = new Intent();
					//Bundle bundle=this.getIntent().getExtras();
					intent.setClass(SxryActivity.this, SxryMActivity.class);
					intent.putExtras(bundle);
					SxryActivity.this.startActivity(intent);
					SxryActivity.this.finish();
				
			}
		});
		
		if(QTRY_EDIT_MEMBER_COUNT!=0){
			memberEditText.setText(QTRY_EDIT_MEMBER_COUNT+"");
		}
	}

//	@Override
//	public boolean onCreateOptionsMenu(Menu menu) {
//		MenuInflater inflater = getMenuInflater();
//		inflater.inflate(R.layout.sxrymenu, menu);
//		return true;
//
//	}
//
//	@Override
//	public boolean onOptionsItemSelected(MenuItem item) {
//		switch (item.getItemId()) {
//		case R.id.button_qd:
//			if(!"其他人员".equals(editText.getText().toString()))
//			QTRY_EDIT_MEMBER=editText.getText().toString();
//			Intent intent = new Intent();
//			Bundle bundle=this.getIntent().getExtras();
//			intent.setClass(SxryActivity.this, Enforcement.class);
//			intent.putExtras(bundle);
//			SxryActivity.this.startActivity(intent);
//			SxryActivity.this.finish();
//			break;
//		case R.id.button_close:
//			break;
//		default:
//			break;
//		}
//		return super.onOptionsItemSelected(item);
//	}

}
